package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjtordermemberdetail;
import com.chezhujie.www.persistence.CzjtordermemberdetailMapper;
import com.sys.core.exception.ClassCheckException;
import com.sys.user.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 会员订单明细
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class CzjtordermemberdetailService extends BaseService<Czjtordermemberdetail> {
    @Autowired
    private CzjtordermemberdetailMapper czjtordermemberdetailMapper;

    @Autowired
    public void setBaseMapper(CzjtordermemberdetailMapper czjtordermemberdetailMapper) {
        this.baseMapper = czjtordermemberdetailMapper;
    }


    public void checkEntity(Czjtordermemberdetail czjtordermemberdetail) throws ClassCheckException {
        if(czjtordermemberdetail.getId()!=null&&czjtordermemberdetail.getId().length()>19){
            throw new ClassCheckException("会员订单明细主键不能超过19个字符");
        }
        if(czjtordermemberdetail.getOrderCode()!=null&&czjtordermemberdetail.getOrderCode().length()>25){
            throw new ClassCheckException("会员订单明细订单编号不能超过25个字符");
        }
        if(czjtordermemberdetail.getCommodityId()!=null&&czjtordermemberdetail.getCommodityId().length()>19){
            throw new ClassCheckException("会员订单明细商品不能超过19个字符");
        }
        if(czjtordermemberdetail.getTitle()!=null&&czjtordermemberdetail.getTitle().length()>100){
            throw new ClassCheckException("会员订单明细订单标题不能超过100个字符");
        }
    }
    public void checkListEntity(List<Czjtordermemberdetail> listCzjtordermemberdetail) throws ClassCheckException {

        for (Czjtordermemberdetail czjtordermemberdetail : listCzjtordermemberdetail) {
            checkEntity(czjtordermemberdetail);
        }

    }

    public Czjtordermemberdetail queryByOrderCode(String orderCode) {
        return czjtordermemberdetailMapper.queryByOrderCode(orderCode);
    }
}
